package io.zhoujie.modules.admin.controller;

import java.util.List;

import io.zhoujie.common.utils.R;
import io.zhoujie.modules.admin.entity.WdReplyEntity;
import io.zhoujie.modules.admin.service.IWdReplyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 问题回复管理Controller
 *
 * @author zhoujie
 * @date 2024-03-18
 */
@RestController
@RequestMapping("admin/reply")
public class WdReplyController {
    @Autowired
    private IWdReplyService wdReplyService;

    /**
     * 查询问题回复管理列表
     */
    @GetMapping("/list")
    public R list(WdReplyEntity wdReplyEntity) {
        List<WdReplyEntity> list = wdReplyService.selectWdReplyList(wdReplyEntity);
        return R.ok().put("page", list);
    }

    /**
     * 获取问题回复管理详细信息
     */
    @GetMapping("/info/{id}")
    public R getInfo(@PathVariable("id") Long id) {
        return R.ok().put("result", wdReplyService.selectWdReplyById(id));
    }

    /**
     * 新增问题回复管理
     */
    @PostMapping("/save")
    public R add(@RequestBody WdReplyEntity wdReplyEntity) {
        int i = wdReplyService.insertWdReply(wdReplyEntity);
        return R.ok().put("result", i);
    }

    /**
     * 修改问题回复管理
     */
    @PutMapping("/update")
    public R edit(@RequestBody WdReplyEntity wdReplyEntity) {
        int i = wdReplyService.updateWdReply(wdReplyEntity);
        return R.ok().put("result", i);
    }

    /**
     * 删除问题回复管理
     */
    @PostMapping("/delete")
    public R remove(@RequestBody Long[] ids) {
        return R.ok().put("result", wdReplyService.deleteWdReplyByIds(ids));
    }
}
